<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<form:form class="layui-form layui-form-pane" modelAttribute="sequence">
	<form:hidden path="sequenceId" />
	<div class="layui-form-item">
		<label class="layui-form-label">选择线路</label>
		<div class="layui-input-inline">
			<form:select path="busLine.lineId" items="${busLineList }"
				itemValue="lineId" itemLabel="fullName" readonly="readonly">
			</form:select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">起始时间</label>
		<div class="layui-input-inline">
			<form:input id="startTime" path="startTime" class="layui-input"
				readonly="readonly"></form:input>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">终到时间</label>
		<div class="layui-input-inline">
			<form:input id="endTime" path="endTime" class="layui-input"
				readonly="readonly" />
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">运行状态</label>
		<div class="layui-input-inline">
			<form:select path="runState">
				<form:option value="运行">运行</form:option>
				<form:option value="停运">停运</form:option>
			</form:select>
		</div>
	</div>
	<div class="layui-form-item">
		<div style="margin-left: 20px;">
			<button class="layui-btn" lay-submit lay-filter="add">修改</button>
		</div>
	</div>
</form:form>
<script type="text/javascript">
	layui.form.render('select');
	layui.laydate.render({
		elem : '#startTime',
		type : 'time',
		format : 'HH:mm'
	});
	layui.laydate.render({
		elem : '#endTime',
		type : 'time',
		format : 'HH:mm'
	});
	layui.form.on('submit(add)', function(data) {
		$.ajax({
			type : "POST",
			url : "sequence/upd",
			data : data.field,
			async : true,
			dataType : "json",
			success : function(res) {
				let msg = "班次修改成功！"
				if (res.code === 0) {
					msg = "班次修改失败！"
				}else if (res.code === -1) {
					msg = "班次已经存在，不能修改！"
				} else if (res.code === -2) {
					msg = "内容没有变化，无需修改！"
				}else if(res.code === -3){
					msg = "数据验证失败！"
				}
				layer.open({
					content : msg,
				});
				if (res.code === 1) {
					loadPage("sequence/showAll")
				}
			}
		});
		return false;
	});
</script>